package sam.msm.dto;

import java.io.Serializable;

import com.alibaba.fastjson.JSONObject;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

@ApiModel
public class ResultDTO implements Serializable {
	private static final long serialVersionUID = 8093957914002719248L;
	@ApiModelProperty(value = "结果码，0为正确，其他均为错误", required = true)
	protected String code = "0";
	@ApiModelProperty(value = "结果内容，统一标准json格式", required = true)
	protected Object data = new JSONObject();
	@ApiModelProperty(value = "结果消息", required = true)
	protected String msg = "";

	public ResultDTO() {
		super();
	}
	public ResultDTO(String msg) {
		super();
		this.msg = msg;
	}
	public ResultDTO(String code, String msg) {
		super();
		this.code = code;
		this.msg = msg;
	}
	public ResultDTO(Object data, String msg) {
		super();
		this.data = data;
		this.msg = msg;
	}
	public ResultDTO(String code, Object data, String msg) {
		super();
		this.code = code;
		this.data = data;
		this.msg = msg;
	}
	/**
	 * 构建默认返回信息
	 * @since 1.0
	 * @param data
	 * @return <br>
	 *         <b>作者： @author 麻亮 <liang.ma@utsoft.cn></b> <br>
	 *         创建时间：2017年5月3日 上午9:10:45
	 */
	public static ResultDTO buildDefault(Object data) {
		return new ResultDTO("0", data, "success");
	}
	/**
	 * 构建默认空返回信息
	 * @since 1.0
	 * @return <br>
	 *         <b>作者： @author 麻亮 <liang.ma@utsoft.cn></b> <br>
	 *         创建时间：2017年5月3日 上午9:31:08
	 */
	public static ResultDTO buildDefault() {
		return buildDefault(new JSONObject());
	}
	public String getCode() {
		return code;
	}
	public Object getData() {
		return data;
	}
	public String getMsg() {
		return msg;
	}
	@Override
	public String toString() {
		return JSONObject.toJSONString(this);
	}
	public void setCode(String code) {
		this.code = code;
	}
	public void setData(Object data) {
		this.data = data;
	}
	public void setMsg(String msg) {
		this.msg = msg;
	}
}
